<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\web\View;

/* @var $this yii\web\View */
/* @var $searchModel app\models\ActivitySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '活动考勤记录';
$this->params['breadcrumbs'][] = $this->title;
$js=<<< Js
var exportLink = document.getElementById('export');
	exportLink.addEventListener('click', function(e){
		e.preventDefault();
		if(e.target.nodeName === "A"){
			tableExport('table-export', '导出文件', e.target.getAttribute('data-type'));
		}

	}, false);
Js;
$this->registerJs($js, View::POS_END, 'myAjax');
?>
<script src="<?= \Yii::getAlias('@web')?>/js/Blob.js"></script>

<script src="<?= \Yii::getAlias('@web')?>/js/FileSaver.js"></script>

<script src="<?= \Yii::getAlias('@web')?>/js/tableExport.js"></script>
<div class="activity-model-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('添加', ['create'], ['class' => 'btn btn-success']) ?>
    <div id="export" style="float: left;margin-right: 4px;" ><a class="btn btn-info"  data-type="xls" href="javascript:;">导出excel</a></div>
    <div id="import" ><a class="btn btn-info"  data-type="xls" href="<?=Yii::getAlias('@web'.'/activity/import')?>">导入excel</a></div>    </p>
    <div class="table-responsive">
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
    	'tableOptions'=>[
    				'id'=>'table-export',
    				'class' => 'table table-striped table-bordered',
    		],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

           // 'id',
            'stu_id',
        	'name',
            'year',
            'semester'=>[
             		'attribute'=>'semester',
             		'filter'=>['1'=>'1','2'=>'2'],
             		
    ],
            'date',
             'time',
             'activity',
            'type'=>[
             		'attribute'=>'type',
             		'filter'=>['缺勤'=>'缺勤','迟到'=>'迟到','早退'=>'早退'],
             		
    ],

            [
            		'class' => 'yii\grid\ActionColumn',
            		
    		],
        ],
    ]); ?>
    </div>
</div>
